package a03demo3;

import java.util.ArrayList;
import java.util.Collections;
import java.util.Random;

public class Test12 {
    public static void main(String[] args) {
        ArrayList<String> list = new ArrayList<>();
        Collections.addAll(list, "a", "b", "c", "d", "e", "f");

        ArrayList<String> list1 = new ArrayList<>();
        Random r = new Random();
        int count = list.size();

        for (int j = 1; j <= 2; j++) {
            System.out.println("第" + j + "次");
            for (int i = 0; i < count; i++) {
                int index = r.nextInt(list.size());
                String name = list.remove(index);
                list1.add(name);
                System.out.println(name);
            }
            list.addAll(list1);
            list1.clear();
        }

    }
}
